# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gst-plugins-base

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}0.10"
pkgver=0.10.36
pkgrel=1
pkgdesc="GStreamer Multimedia Framework Base Plugins (mingw-w64)"
arch=('any')
url="http://gstreamer.freedesktop.org/"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
    "${MINGW_PACKAGE_PREFIX}-pkg-config"
    "${MINGW_PACKAGE_PREFIX}-libvorbis"
    "${MINGW_PACKAGE_PREFIX}-libtheora"
    "${MINGW_PACKAGE_PREFIX}-pango"
    #"${MINGW_PACKAGE_PREFIX}-gobject-introspection"
    #"${MINGW_PACKAGE_PREFIX}-libvisual"
    #"${MINGW_PACKAGE_PREFIX}-cdparanoia"
    "${MINGW_PACKAGE_PREFIX}-gstreamer0.10"
    "${MINGW_PACKAGE_PREFIX}-orc"
    )
options=(!libtool strip staticlibs)
source=(${url}/src/${_realname}/${_realname}-${pkgver}.tar.xz
    fix-crash-0-byte-ogg.patch
        colorbalance-fix-abi.patch
        revert-decodebin-playbin-removal.patch
        videoscale-fix-negotiation.patch
        ayuv64-lanczos.patch
        gstaudio-symbols.patch
    gst-plugins-base-0.10.36-warnings.patch
    gst-plugins-base-0.10.28-gnomevfswin32.patch
    0001-fix-test-compilation.mingw.patch
    0002-fix-test-running.mingw.patch
    0003-fix-riff-includes.mingw.patch
    0004-fix-X-detection.mingw.patch)

md5sums=('3d2337841b132fe996e5eb2396ac9438'
         '87b3fe9b5ffdb04fe9d2e7665c901a6b'
         'babecf0eb6c88cd1f5b684cfa7335117'
         '9799a2079ac98e3e149fad3196d81bbc'
         '9c21828265688fd258aa34bb5c1709aa'
         'a52d29391633eef13c4ea123ffb6ad0e'
         'c19ff07e8682543374806315fd6613c1'
         'ea7fe94523d11559272c8d1ea4cd62c4'
         'a64b9d27ab701107accd9c2e35ce7312'
         '4840ec99f2fb08117495bbcbad008e60'
         'd5e43e1df35664688f4c5123be668ad0'
         '571194f25c8c765b5b5e5739df1271ae'
         '87505c16e53f5b19a2cd0958a6138a63')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  
  sed -i -e '/AC_PATH_XTRA/d' -e 's/AM_CONFIG_HEADER/AC_CONFIG_HEADERS/' configure.ac
  patch -Np1 -i ${srcdir}/fix-crash-0-byte-ogg.patch
  patch -Np1 -i ${srcdir}/colorbalance-fix-abi.patch
  patch -Np1 -i ${srcdir}/ayuv64-lanczos.patch
  patch -Np1 -i ${srcdir}/videoscale-fix-negotiation.patch
  patch -Np1 -i ${srcdir}/gstaudio-symbols.patch
  #patch  -Rp1 -i ${srcdir}/revert-decodebin-playbin-removal.patch
  
  patch -Np0 -i ${srcdir}/gst-plugins-base-0.10.36-warnings.patch
  patch -Np1 -i ${srcdir}/gst-plugins-base-0.10.28-gnomevfswin32.patch
  
  patch -p1 -i ${srcdir}/0001-fix-test-compilation.mingw.patch
  patch -p1 -i ${srcdir}/0002-fix-test-running.mingw.patch
  patch -p1 -i ${srcdir}/0003-fix-riff-includes.mingw.patch
  patch -p1 -i ${srcdir}/0004-fix-X-detection.mingw.patch
  
  NOCONFIGURE=1 ./autogen.sh
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  cp -r "${srcdir}/${_realname}-${pkgver}" "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --disable-static \
    --enable-shared \
    --enable-silent-rules \
    --enable-experimental \
    --disable-gtk-doc \
    --disable-vorbistest \
    --disable-freetypetest \
    --disable-examples
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make -j1 DESTDIR="$pkgdir" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
  rm -f ${pkgdir}${MINGW_PREFIX}/lib/gstreamer-*/*.a
}
